by Jafo C - Null (3 Submissions)
Category: Miscellaneous
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Mon 1st April 2002
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Adds an "\" If needed, quit the "\" when needed too...
'
'FuncMode.- (0 or 1), if you set 1 comparePath will add an "\", if you set to
'0 ComparePath will remove the "\".
'
'You can put a FileName too.
'EX.
'
'ComparePath "C:\windows\system",1,"Kernel32.dll"
'Result Will Be: C:\windows\system\Kernel32.dll
'
'DO NOT USE A file name With FuncMode= 0
'--------------------------
Function ComparePath(ByVal strPathName As String, ByVal funcMode As Integer, Optional ByVal strFilename As String) As String
Dim aux As Integer
If funcMode = 1 Then
If Right(Trim(strPathName), Len("\")) <> "\" Then
ComparePath = Trim$(RTrim$(strPathName) & "\" & Trim$(strFilename))
Else
ComparePath = Trim$(RTrim$(strPathName) & Trim$(strFilename))
End If
Else
If strFilename <> "" Then
Err.Raise 1, , "Function can't use mode 0 with a file name."
Exit Function
End If
If Right(Trim(strPathName), Len("\")) <> "\" Then
ComparePath = Trim$(RTrim$(strPathName))
Else
aux = Len(strPathName)
ComparePath = Trim$(RTrim$(Left$(strPathName, aux - 1)))
End If
End If
End Function